From c2faf9e511f2fbcc8705c6883408a90d1c01a537 Mon Sep 17 00:00:00 2001 From: Hollis Blanchard Date: Fri, 2 Mar 2007 17:06:50 -0600 Subject: [PATCH] [POWERPC][XEN] Introduce "platform" abstraction to describe the IO hole. Signed-off-by: Ryan Harper Signed-off-by: Hollis Blanchard --HG-- extra : transplant_source : %D12%89%D7%E6%1B3Y%EA%E9%D85IU%22%AD%29%AC%C1%B1 --- xen/arch/powerpc/Makefile | 1 + xen/arch/powerpc/mm.c | 5 ++-- xen/arch/powerpc/papr/xlate.c | 3 +- xen/arch/powerpc/platform.c | 43 +++++++++++++++++++++++++++++ xen/arch/powerpc/powerpc64/ppc970.c | 12 -------- xen/include/asm-powerpc/processor.h | 1 - xen/include/asm/platform.h | 28 +++++++++++++++++++ 7 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 xen/arch/powerpc/platform.c create mode 100644 xen/include/asm/platform.h diff --git a/xen/arch/powerpc/Makefile b/xen/arch/powerpc/Makefile index 669fce0e73..f20580f6ce 100644 --- a/xen/arch/powerpc/Makefile +++ b/xen/arch/powerpc/Makefile @@ -33,6 +33,7 @@ obj-y += of-devwalk.o obj-y += ofd_fixup.o obj-y += ofd_fixup_memory.o obj-y += physdev.o +obj-y += platform.o obj-y += rtas.o obj-y += setup.o obj-y += shadow.o diff --git a/xen/arch/powerpc/mm.c b/xen/arch/powerpc/mm.c index ae53469d90..2a8686c890 100644 --- a/xen/arch/powerpc/mm.c +++ b/xen/arch/powerpc/mm.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -426,7 +427,7 @@ ulong pfn2mfn(struct domain *d, ulong pfn, int *type) /* Its a grant table access */ t = PFN_TYPE_GNTTAB; mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page)); - } else if (d->is_privileged && cpu_io_mfn(pfn)) { + } else if (d->is_privileged && platform_io_mfn(pfn)) { t = PFN_TYPE_IO; mfn = pfn; } else { @@ -512,7 +513,7 @@ unsigned long mfn_to_gmfn(struct domain *d, unsigned long mfn) return max_page + (mfn - gnttab_mfn); /* IO? */ - if (d->is_privileged && cpu_io_mfn(mfn)) + if (d->is_privileged && platform_io_mfn(mfn)) return mfn; rma_mfn = page_to_mfn(d->arch.rma_page); diff --git a/xen/arch/powerpc/papr/xlate.c b/xen/arch/powerpc/papr/xlate.c index a476691f74..1d197dd0d4 100644 --- a/xen/arch/powerpc/papr/xlate.c +++ b/xen/arch/powerpc/papr/xlate.c @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef DEBUG #define DBG(fmt...) printk(fmt) @@ -536,7 +537,7 @@ long pte_remove(ulong flags, ulong ptex, ulong avpn, ulong *hi, ulong *lo) if (lpte.bits.v) { ulong mfn = lpte.bits.rpn; - if (!cpu_io_mfn(mfn)) { + if (!platform_io_mfn(mfn)) { struct page_info *pg = mfn_to_page(mfn); struct domain *f = page_get_owner(pg); diff --git a/xen/arch/powerpc/platform.c b/xen/arch/powerpc/platform.c new file mode 100644 index 0000000000..459450ef59 --- /dev/null +++ b/xen/arch/powerpc/platform.c @@ -0,0 +1,43 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2007 + * + * Authors: Ryan Harper + * Hollis Blanchard + */ + +#include +#include + +#define IO_RANGE_START (2UL << 30) +#define IO_RANGE_END (4UL << 30) +#define IO_SIZE (IO_RANGE_END - IO_RANGE_START) + +unsigned long platform_iohole_base(void) +{ + return IO_RANGE_START; +} + +unsigned long platform_iohole_size(void) +{ + return IO_SIZE; +} + +int platform_io_mfn(unsigned long mfn) +{ + unsigned long maddr = mfn << PAGE_SHIFT; + return maddr > IO_RANGE_START && maddr < IO_RANGE_END; +} diff --git a/xen/arch/powerpc/powerpc64/ppc970.c b/xen/arch/powerpc/powerpc64/ppc970.c index 64a05571f6..415f8bbdce 100644 --- a/xen/arch/powerpc/powerpc64/ppc970.c +++ b/xen/arch/powerpc/powerpc64/ppc970.c @@ -129,18 +129,6 @@ unsigned int cpu_extent_order(void) return log_large_page_sizes[0] - PAGE_SHIFT; } -/* This is more a platform thing than a CPU thing, but we only have - * one platform now */ -int cpu_io_mfn(ulong mfn) -{ - /* totally cheating */ - if (mfn >= (2UL << (30 - PAGE_SHIFT)) && /* 2GiB */ - mfn < (4UL << (30 - PAGE_SHIFT))) /* 4GiB */ - return 1; - - return 0; -} - int cpu_threads(int cpuid) { return 1; diff --git a/xen/include/asm-powerpc/processor.h b/xen/include/asm-powerpc/processor.h index 3a4ad04260..fe43304e82 100644 --- a/xen/include/asm-powerpc/processor.h +++ b/xen/include/asm-powerpc/processor.h @@ -124,7 +124,6 @@ extern int cpu_rma_valid(unsigned int order); extern uint cpu_large_page_orders(uint *sizes, uint max); extern void cpu_initialize(int cpuid); extern void cpu_init_vcpu(struct vcpu *); -extern int cpu_io_mfn(ulong mfn); extern int cpu_threads(int cpuid); extern void save_cpu_sprs(struct vcpu *); extern void load_cpu_sprs(struct vcpu *); diff --git a/xen/include/asm/platform.h b/xen/include/asm/platform.h new file mode 100644 index 0000000000..74e810af7a --- /dev/null +++ b/xen/include/asm/platform.h @@ -0,0 +1,28 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright IBM Corp. 2007 + * + * Authors: Ryan Harper + */ + +#ifndef _ASM_PLATFORM_H_ +#define _ASM_PLATFORM_H_ + +extern unsigned long platform_iohole_base(void); +extern unsigned long platform_iohole_size(void); +extern int platform_io_mfn(unsigned long mfn); + +#endif -- 2.30.2